package com.zj.guava.eventbus.DirectoryAndFileWatch;

import com.google.common.eventbus.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.nio.file.Path;

public class FileChangeListener {
    Logger logger = LoggerFactory.getLogger(FileChangeListener.class);

    @Subscribe
    public void onChange(FileChangeEvent event) {
        Path path = event.getPath();
        String fileName = path.getFileName().toString();
        boolean is = fileName.endsWith("txt");
        if (fileName.endsWith("txt")) {
            logger.info("{}->{}", event.getPath(), event.getKind());
        }

    }
}
